String Class
Extensions to the String class.
Constructor
String
()
Item Index
Methods
repeat
(
String
-
n
Returns the string repeated n times.
var s = "~-";
console.log(s.repeat(10));
// ~-~-~-~-~-~-~-~-~-~-
Parameters:
-
n
Int
Returns:
String:
If n is NaN then return the string else return repeated string.
replaceChars
(
String
-
tar
-
rep
Replaces all target characters with the replacement character. Works by splitting it into an array and then rejoining it.
var s = "Intro to Javascript";
console.log(s.replaceChars(" ", "_"));
// Intro_to_Javascript
Returns:
String:
with target characters replaced
reverse
()
String
Reverses the characters in a string.
var s = "Intro to Javascript";
console.log(s.reverse());
// tpircSavaJ ot ortnI